﻿using Kingdee.BOS.Core.CommonFilter;
using Kingdee.BOS.Core.DynamicForm.PlugIn;
using Kingdee.BOS.Core.DynamicForm.PlugIn.Args;
using Kingdee.BOS.Util;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace RK.FormPlugin.XHX
{
    [Description("【表单插件】多选辅助资料"), HotUpdate]
    public class DzBeforeControlDataBinder : AbstractDynamicFormPlugIn
    {
        const string ButtonKey = "F_SELECT_DATA";
        public override void BeforeControlDataBinder(BeforeControlDataBinder e)
        {
            base.BeforeControlDataBinder(e);
            // 启用   
            this.View.GetControl(ButtonKey).Enabled = true;
            this.View.GetControl(ButtonKey).Visible = true;
            // 目前尚未支持自定义背景色，希望未来版本可以支持  
            this.View.GetControl(ButtonKey).SetCustomPropertyValue("BackClor", "#80FFFF");
            // 设置前景色   
            this.View.GetControl(ButtonKey).SetCustomPropertyValue("ForeColor", "#1E90FF");
        }
        public override void BarItemClick(BarItemClickEventArgs e)
        {
            base.BarItemClick(e);
            // 启用   
            this.View.GetControl(ButtonKey).Enabled = true;
            this.View.GetControl(ButtonKey).Visible = true;
            // 目前尚未支持自定义背景色，希望未来版本可以支持  
            this.View.GetControl(ButtonKey).SetCustomPropertyValue("BackClor", "#80FFFF");
            // 设置前景色   
            this.View.GetControl(ButtonKey).SetCustomPropertyValue("ForeColor", "#1E90FF");
            return;

        }
        public override void ButtonClick(ButtonClickEventArgs e)
        {
            base.ButtonClick(e);
            if (e.Key.Equals(ButtonKey, StringComparison.OrdinalIgnoreCase))
            {
                var showParameter = new FilterShowParameter();
                showParameter.FormId = "PLN_PLANORDER";
                showParameter.ParentPageId = this.View.PageId;
                this.View.ShowForm(showParameter);
                return;
            }
        }
    }
}
